package com.cainaer.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cainaer.common.core.utils.StringUtils;
import com.cainaer.product.domain.ProductCategory;
import com.cainaer.product.mapper.ProductCategoryMapper;
import com.cainaer.product.service.IProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 分类表 服务实现类
 * </p>
 *
 * @author Tina
 * @since 2020-09-11
 */
@Service
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategory> implements IProductCategoryService {

    @Autowired
    private ProductCategoryMapper productCategoryMapper;

    /**
     * 查询商品分类
     *
     * @param productCategory
     * @return
     */
    @Override
    public List<ProductCategory> selectProductCategories(ProductCategory productCategory) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("show_status", 0);
        queryWrapper.eq("shop_id", productCategory.getShopId());
        return productCategoryMapper.selectList(queryWrapper);
    }

    /**
     * 新增分类
     *
     * @param productCategory
     * @return
     */
    @Override
    public Integer insertProductCategory(ProductCategory productCategory) {
        return productCategoryMapper.insert(productCategory);
    }

    /**
     * 编辑分类
     *
     * @param productCategory
     * @return
     */
    @Override
    public Integer editProductCategory(ProductCategory productCategory) {

        return productCategoryMapper.updateById(productCategory);
    }
}
